﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using QLTV_Public;


namespace QLTV_Data
{
  public  class SinhVien_Data
    {
      KetNoiCSDL_Data kn = new KetNoiCSDL_Data();
      public DataTable TaoBang(string sql)
      {
          return kn.taobang(sql);
      }
      public DataTable LayDuLieu()
      {
          return kn.LayDuLieu("Load_SinhVien");
      }
      public DataTable Load_HocVien_Edit(string maDocGia)
      {
          string[]name=new string[1];
          object[]value=new object[1];
          name[0]="@MaDocGia";
          value[0]=maDocGia;
          return kn.LayDuLieu("Load_HocVien_Edit",name,value,1);
      }
      public int Insert(SinhVien_Public maDocGia, SinhVien_Public anh, SinhVien_Public hoVaTen, SinhVien_Public gioiTinh, SinhVien_Public ngaySinh, SinhVien_Public maDanToc, SinhVien_Public trinhDoVH, SinhVien_Public maLop,  SinhVien_Public dienThoai, SinhVien_Public email)
      {
          int Npara = 10;
          string[] name = new string[Npara];
          object[] value = new object[Npara];
          name[0] = "@MaDocGia";
          value[0] = maDocGia.MaDocGia;
          name[1] = "@Anh";
          value[1] = anh.Anh;
          name[2] = "@HoVaTen";
          value[2] = hoVaTen.HoVaTen;
          name[3] = "@GioiTinh";
          value[3] = gioiTinh.GioiTinh;
          name[4] = "@NgaySinh";
          value[4] = ngaySinh.NgaySinh;
          name[5] = "@MaDanToc";
          value[5] = maDanToc.MaDanToc;
          name[6] = "@TrinhDoVanHoa";
          value[6] = trinhDoVH.TrinhDoVanHoa;
          name[7] = "@MaLop";
          value[7] = maLop.MaLop;
          name[8] = "@SoDienThoai";
          value[8] = dienThoai.SoDienThoai;
          name[9] = "@Email";
          value[9] = email.Email;

          return kn.update("Insert_SinhVien",name,value,Npara);
      }
      public int Update(SinhVien_Public maDocGia, SinhVien_Public anh, SinhVien_Public hoVaTen, SinhVien_Public gioiTinh, SinhVien_Public ngaySinh, SinhVien_Public maDanToc, SinhVien_Public trinhDoVH, SinhVien_Public maLop, SinhVien_Public dienThoai, SinhVien_Public email)
      {
          int Npara = 10;
          string[] name = new string[Npara];
          object[] value = new object[Npara];
          name[0] = "@MaDocGia";
          value[0] = maDocGia.MaDocGia;
          name[1] = "@Anh";
          value[1] = anh.Anh;
          name[2] = "@HoVaTen";
          value[2] = hoVaTen.HoVaTen;
          name[3] = "@GioiTinh";
          value[3] = gioiTinh.GioiTinh;
          name[4] = "@NgaySinh";
          value[4] = ngaySinh.NgaySinh;
          name[5] = "@MaDanToc";
          value[5] = maDanToc.MaDanToc;
          name[6] = "@TrinhDoVanHoa";
          value[6] = trinhDoVH.TrinhDoVanHoa;
          name[7] = "@MaLop";
          value[7] = maLop.MaLop;
          name[8] = "@SoDienThoai";
          value[8] = dienThoai.SoDienThoai;
          name[9] = "@Email";
          value[9] = email.Email;

          return kn.update("Update_SinhVien", name, value, Npara);
      }
      public int Delete(SinhVien_Public maDocGia)
      {
          int Npara = 1;
          string[] name = new string[Npara];
          object[] value = new object[Npara];
          name[0] = "@MaDocGia";
          value[0] = maDocGia.MaDocGia;

          return kn.update("Delete_SinhVien", name, value, Npara);
      }
    }
}
